﻿using System;
namespace Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000 {
    
    
    [global::Xtee.Core.Attributes.XmlTypeAttribute(Name="atm1List", Namespace="http://producers.ehma-10000000.xtee.riik.ee/producer/ehma-10000000", Target=typeof(Atm1List))]
    public class Atm1ListSerializer : global::Xtee.Core.Types.AbstractXteeSerializable {
        
        protected IAtm1List clazz;
        
        public Atm1ListSerializer(IAtm1List clazz) {
            this.clazz = clazz;
        }
        
        public override void WriteXml(global::Xtee.Core.IXteeXmlWriter Writer) {
            base.WriteXml(Writer);
            for (int x = 0; ((clazz.Atm1 != null) 
                        && (x < clazz.Atm1.Count)); x = (x + 1)) {
                if (clazz.Atm1[x]!=null) {
                    Writer.WriteStartElement("atm1");
                    global::Xtee.Core.SerializationMetadata metaAtm1 = this.GetMetaData(clazz.Atm1[x]);
                    Writer.WriteTypeAttribute(metaAtm1.TypeQualifiedName.Namespace, metaAtm1.TypeQualifiedName.Name);
                    metaAtm1.NewSerializer(clazz.Atm1[x]).WriteXml(Writer);
                    Writer.WriteEndElement();
                }
            }
        }
        
        public override void ReadXml(global::Xtee.Core.IXteeXmlReader Reader) {
            base.ReadXml(Reader);
            if (Reader.LocalName=="atm1") {
                clazz.Atm1 = new System.Collections.Generic.List<global::Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000.IAtm1>();
                for (; ((Reader.NodeType != System.Xml.XmlNodeType.EndElement) 
                            && (Reader.LocalName == "atm1")); ) {
                    if (Reader.IsElementNil()) {
                        throw new global::Xtee.Core.Exceptions.NillableNotAllowedException(">>atm1List>atm1");
                    }
                    global::Xtee.Core.SerializationMetadata metaAtm1 = this.GetMetaData<global::Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000.IAtm1>(Reader, "atm1", "http://producers.ehma-10000000.xtee.riik.ee/producer/ehma-10000000");
                    global::Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000.IAtm1 item = metaAtm1.NewEntity<global::Producers.Ehma10000000.Xtee.Riik.Ee.Producer.Ehma10000000.IAtm1>();
                    clazz.Atm1.Add(item);
                    if ((Reader.IsEmptyElement == false)) {
                        Reader.ReadStartElement("atm1");
                        metaAtm1.NewSerializer(item).ReadXml(Reader);
                        Reader.ReadEndElement();
                    }
                    else {
                        Reader.Skip();
                    }
                }
            }
        }
    }
}
